<?php
class LoginAction extends BaseAction
{

    public function index()
    {
        if (!$this->isPost())
        {
            $this->display();
        }
        else
        {
            /* if($_POST['Inputs']==''){
					$this->assign("jumpUrl","__URL__/index");
					$this->assign("",3);
					$this->error("请接受用户条款");
				} */
            $v_email = $_POST['v_name'];
            $pwd = md5($_POST['v_pwd']);
            $result = M("vip")->where("v_email='$v_email' and v_pwd ='$pwd'")->find();
            if ($result)
            {
                $_SESSION['userinfo'] = $result;
                $this->redirect('Index/index', array(
                    'cate_id' => 2
                ), 0);
            }
            else
            {
                $this->assign("jumpUrl", "__URL__/index");
                $this->assign("", 3);
                $this->error("用户名或密码错误！！！");
            
            }
        }
    
    }

    public function verify()
    {
        import("ORG.Util.Image");
        Image::buildImageVerify();
    }
    
    public function ajaxlogin()
    {
    	$email = trim($_GET['name']);
    	$password = md5(trim($_GET['password']));
    	$result = M("vip")->where("v_email='$email' and v_pwd ='$password'")->find();
    	if($result)
    	{
    		$_SESSION['userinfo'] = $result;
    		$data = array('error'=>1, 'data'=>$result);
    	}
    	else
    	{
    		$data = array('error'=>0, 'data'=>null);
    	}
    	exit(json_encode($data));
    }
    
    public function ajaxlogout()
    {
    	$_SESSION = array();
    	unset($_SESSION);
    	exit('success');
    }

}

?>